package com.haidechizi.i18n.spring.boot.autoconfigure;

import com.haidechizi.i18n.common.config.Configuration;
import com.haidechizi.i18n.spring.boot.properties.I18nProperties;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.core.annotation.Order;

@Order(-100)
@org.springframework.context.annotation.Configuration
@EnableConfigurationProperties(I18nProperties.class)
public class I18nAutoConfiguration {
    @Autowired
    private I18nProperties i18nProperties;

    @Bean
    @ConditionalOnMissingBean
    public Configuration configuration() {
        Configuration configuration = new Configuration();
        BeanUtils.copyProperties(i18nProperties, configuration);
        return configuration;
    }

}
